home *** CD-ROM | disk | FTP | other *** search
- // MFCSPELL.H
- //
- // Copyright (c) 1999 by POLAR. All Rights Reserved.
- //
- // mfcspell.h - MFC wrapper for POLSPELL.DLL (user accessible classes)
- //
- //
-
-
- #ifndef __POLMFCSPELL_H
- #define __POLMFCSPELL_H
-
-
- #include "polspell.h"
-
- // TSpellingChecker - MFC wrapper for POLSPELL.DLL API-s (all functions must be inline)
-
- class TSpellingChecker
- {
- private:
- HSPELL m_hSpell;
-
- public:
- TSpellingChecker();
- ~TSpellingChecker();
-
- BOOL OpenDictionary(LPCTSTR pszMainDictFileName, LPCTSTR pszCustomDictFileName);
- void CloseDictionary();
- BOOL Reset();
- CString GetLanguageName(LPCTSTR pszDictFileName);
- BOOL IsWordExist(LPCTSTR pszWord);
- void AddToChangeAll(LPCTSTR pszFind, LPCTSTR pszReplace);
- void AddToIgnoreAll(LPCTSTR pszWord);
- BOOL IsCharAlpha(short ch);
- BOOL IsCharLower(short ch);
- BOOL IsCharUpper(short ch);
- CString GetReplacement(LPCTSTR pszWord);
- CString GetSuggestion(LPCTSTR pszWord, short nSuggestionIndex);
- void AddWord(LPCTSTR pszNewWord);
- CString CheckText(LPCTSTR pszText, short *pnExitStatus);
- BOOL GetAlwaysSuggest();
- void SetAlwaysSuggest(BOOL bNewValue);
- BOOL GetIgnoreWordsInUppercase();
- void SetIgnoreWordsInUppercase(BOOL bNewValue);
- BOOL GetIgnoreWordsWithNumbers();
- void SetIgnoreWordsWithNumbers(BOOL bNewValue);
- BOOL DownloadDictionaries(LPCTSTR pszUpdateURL, LPCTSTR pszInstallDir);
- BOOL OptionsDialog(LPCTSTR pszDictionaryDir, LPTSTR pszCustomDicFileName, unsigned nCustomDicSize,
- LPTSTR pszCurDicFileName, unsigned nCurDicSize, LPCTSTR pszURL, BOOL bInternetSupport);
- };
-
-
- ////////////////////////////////////////////////////////////////////////////////
- // Inline functions
-
-
- inline TSpellingChecker::TSpellingChecker()
- {
- m_hSpell = PS_Init();
- }
-
- inline TSpellingChecker::~TSpellingChecker()
- {
- PS_Destroy(m_hSpell);
- }
-
- inline BOOL TSpellingChecker::OpenDictionary(LPCTSTR pszMainDictFileName, LPCTSTR pszCustomDictFileName)
- {
- return PS_OpenDictionary(m_hSpell, pszMainDictFileName, pszCustomDictFileName);
- }
-
- inline void TSpellingChecker::CloseDictionary()
- {
- PS_CloseDictionary(m_hSpell);
- }
-
- inline BOOL TSpellingChecker::Reset()
- {
- return PS_Reset(m_hSpell);
- }
-
- inline CString TSpellingChecker::GetLanguageName(LPCTSTR pszDictFileName)
- {
- CString strLang;
-
- PS_GetLanguageName(m_hSpell, pszDictFileName, strLang.GetBuffer(256), 256-1);
- strLang.ReleaseBuffer();
-
- return strLang;
- }
-
- inline BOOL TSpellingChecker::IsWordExist(LPCTSTR pszWord)
- {
- return PS_IsWordExist(m_hSpell, pszWord);
- }
-
- inline void TSpellingChecker::AddToChangeAll(LPCTSTR pszFind, LPCTSTR pszReplace)
- {
- PS_AddToChangeAll(m_hSpell, pszFind, pszReplace);
- }
-
- inline void TSpellingChecker::AddToIgnoreAll(LPCTSTR pszWord)
- {
- PS_AddToIgnoreAll(m_hSpell, pszWord);
- }
-
- inline BOOL TSpellingChecker::IsCharAlpha(short ch)
- {
- return PS_IsCharAlpha(m_hSpell, ch);
- }
-
- inline BOOL TSpellingChecker::IsCharLower(short ch)
- {
- return PS_IsCharLower(m_hSpell, ch);
- }
-
- inline BOOL TSpellingChecker::IsCharUpper(short ch)
- {
- return PS_IsCharUpper(m_hSpell, ch);
- }
-
- inline CString TSpellingChecker::GetReplacement(LPCTSTR pszWord)
- {
- CString strResult;
-
- PS_GetReplacement(m_hSpell, pszWord, strResult.GetBuffer(256), 256-1);
- strResult.ReleaseBuffer();
- return strResult;
- }
-
- inline CString TSpellingChecker::GetSuggestion(LPCTSTR pszWord, short nSuggestionIndex)
- {
- CString strResult;
-
- PS_GetSuggestion(m_hSpell, pszWord, nSuggestionIndex, strResult.GetBuffer(256), 256-1);
- strResult.ReleaseBuffer();
- return strResult;
- }
-
- inline void TSpellingChecker::AddWord(LPCTSTR pszNewWord)
- {
- PS_AddWord(m_hSpell, pszNewWord);
- }
-
- inline CString TSpellingChecker::CheckText(LPCTSTR pszText, short *pnExitStatus)
- {
- CString strResult;
-
- strResult.Empty();
- HGLOBAL hglb = PS_CheckText(m_hSpell, pszText, pnExitStatus);
- if(hglb)
- {
- LPTSTR psz = (LPTSTR)GlobalLock(hglb);
- if(psz)
- {
- strResult = psz;
- GlobalUnlock(hglb);
- }
- GlobalFree(hglb);
- }
- return strResult;
- }
-
- inline BOOL TSpellingChecker::GetAlwaysSuggest()
- {
- return PS_GetAlwaysSuggest(m_hSpell);
- }
-
- inline void TSpellingChecker::SetAlwaysSuggest(BOOL bNewValue)
- {
- PS_SetAlwaysSuggest(m_hSpell, bNewValue);
- }
-
- inline BOOL TSpellingChecker::GetIgnoreWordsInUppercase()
- {
- return PS_GetIgnoreWordsInUppercase(m_hSpell);
- }
-
- inline void TSpellingChecker::SetIgnoreWordsInUppercase(BOOL bNewValue)
- {
- PS_SetIgnoreWordsInUppercase(m_hSpell, bNewValue);
- }
-
- inline BOOL TSpellingChecker::GetIgnoreWordsWithNumbers()
- {
- return PS_GetIgnoreWordsWithNumbers(m_hSpell);
- }
-
- inline void TSpellingChecker::SetIgnoreWordsWithNumbers(BOOL bNewValue)
- {
- PS_SetIgnoreWordsWithNumbers(m_hSpell, bNewValue);
- }
-
- inline BOOL TSpellingChecker::DownloadDictionaries(LPCTSTR pszUpdateURL, LPCTSTR pszInstallDir)
- {
- return PS_DownloadDictionaries(m_hSpell, pszUpdateURL, pszInstallDir);
- }
-
- inline BOOL TSpellingChecker::OptionsDialog(LPCTSTR pszDictionaryDir, LPTSTR pszCustomDicFileName,
- unsigned nCustomDicSize, LPTSTR pszCurDicFileName,
- unsigned nCurDicSize, LPCTSTR pszURL, BOOL bInternetSupport)
- {
- return PS_OptionsDialog(m_hSpell, pszDictionaryDir, pszCustomDicFileName, nCustomDicSize, pszCurDicFileName,
- nCurDicSize, pszURL, bInternetSupport);
- }
-
- #endif